package com.itjiange;

/**
 * 会员访问者：cpu 打八折、内存 打六折
 *
 * @author ItJianGe
 * @data 2024/8/27 10:06
 */
public class MemberVisitor implements Visitor {

    private int priceTotal;

    @Override
    public void visitorCpu(Cpu cpu) {
        // 会员打八折
        int price = (int) (cpu.price() * 0.8);
        priceTotal += price;
        System.out.println("【会员访问者】CPU 价格：" + price + " 描述：" + cpu.desc());
    }

    @Override
    public void visitorMemory(Memory memory) {
        int price = (int) (memory.price() * 0.6);
        priceTotal += price;
        System.out.println("【会员访问者】内存 价格：" + price + " 描述：" + memory.desc());
    }

    @Override
    public int price() {
        return priceTotal;
    }

    @Override
    public String visitorName() {
        return "会员访问者";
    }
}
